import axios from '../axios'

/* 
 * 智能预警模块
 */

// 保存
export const save = (data) => {
    return axios({
        url: '/warning/save',
        method: 'post',
        data
    })
}

// 删除
export const batchDelete = (data) => {
    return axios({
        url: '/warning/delete',
        method: 'post',
        data
    })
}

// 分页查询
export const findPage = (data) => {
    return axios({
        url: '/warning/findPage',
        method: 'post',
        data
    })
}

// 查询详情
export const findById = (id) => {
    return axios({
        url: '/warning/findById?id=' + id,
        method: 'get'
    })
}

// 获取当前用户的预警信息
export const findCurrentUserWarnings = (status) => {
    let url = '/warning/findCurrentUserWarnings';
    if (status !== undefined) {
        url += '?status=' + status;
    }
    return axios({
        url: url,
        method: 'get'
    })
}

// 统计未读预警数量
export const countUnread = (studentNum) => {
    return axios({
        url: '/warning/countUnread?studentNum=' + studentNum,
        method: 'get'
    })
}

// 标记为已读
export const markAsRead = (id) => {
    return axios({
        url: '/warning/markAsRead?id=' + id,
        method: 'post'
    })
}

// 标记全部为已读
export const markAllAsRead = (studentNum) => {
    return axios({
        url: '/warning/markAllAsRead?studentNum=' + studentNum,
        method: 'post'
    })
}

// 创建心理测评预警
export const createPsyWarning = (studentNum, termId, score) => {
    return axios({
        url: '/warning/createPsyWarning?studentNum=' + studentNum + '&termId=' + termId + '&score=' + score,
        method: 'post'
    })
} 